package com.hxd.mall.module.usercenter.home

import com.hxd.mall.network.base.BaseRequest
import com.hxd.mall.network.service.ManagerFunctionApi
import com.hxd.mall.utils.open.ToastUtil
import javax.inject.Inject

/**
 * @author zhaoyong
 * @description:
 * @date :2019/7/17 11:08 AM
 */
class MinePresenter @Inject constructor(var mView: IMineView) : IMinePresenter {
    //获取banner数据
    override fun getBannerData() {
        ManagerFunctionApi.mIMeFunctionApi.fetchBanner().run {
                BaseRequest.request(this, mView,{
                    mView.showBannerData(it)
                }, {
                    ToastUtil.showToast(it.msg ?: "")
                })
        }
    }

    override fun getData(isRefresh: Boolean) {
        ManagerFunctionApi.mIMeFunctionApi.personalInfo().run {
            if (isRefresh){
                BaseRequest.request(this, mView,{
                    mView.showData(it, isRefresh)
                }, {
                    ToastUtil.showToast(it.msg ?: "")
                })
            }else {
                BaseRequest.request(this, {
                    mView.showData(it, isRefresh)
                }, {
                    ToastUtil.showToast(it.msg ?: "")
                })
            }
        }
    }


//    override fun getData(isRefresh: Boolean) {
//        mIMeFunctionApi.personalInfo().run {
//            if (isRefresh) {
//                BaseRequest.request(this, {
//
//                }, {
//                })
//            } else {
//                BaseRequest.requestFinishRefresh(this, mView, {
//                    mView.showData(it)
//                }, {
//                    //            Logger.i("request fail")
//                }, false)
//            }
//        }
//    }

}